<!--
content_type templates should copy or extend this.
-->
<div class="minerva_content">

{% if not embed %}
<div class="minerva_content_top">
  {% if not content %}
    <img class="icon" src="/static/images/icons/{{ content_type.name }}.png">
        {{ content_type.name }}
        </img>
    <p>{{ content_type.desc }}</p>
  {% else %}
    <h2>{{ content.title }}</h2>
  {% endif %}
</div>
{% endif %}

<div class="minerva_content_mid">
  {% if editor %}
    <!--
    Content editor
    -->
    <form method="post">
    <input type="hidden" name="content_type" value="{{ content_type.name }}"></input>

    <div class="buttons">
      <input type="submit" value="Done"/>
      </div>

    <fieldset>
    <ol>
      <li><label for="title">title</label>
      <input id="title" name="title" value="{{ content.title }}"/>
      </li>
      {% block fields %}{% endblock %}
    </ol>
    </fieldset>
    {% block form_extra %}{% endblock %}
    </form>

    <script>
    var replaceMid = function(html) {
      var mid = $('#mid');
      if (mid.size()) {
        mid.html(html);
        }
    }
    $('form input, form textarea').focus(function() {
        console.log('input element received focus:', this);
        minerva.infocus = this;
        });
    $('form').ajaxForm({success: replaceMid});
    {% block editor_script_extra %}{% endblock %}
    </script>

  {% else %}
    <!--
    Content viewer
    -->
    {% if user_is_author and not embed %}
      <a id="editon" class="action" onclick="(function() {
          $.get('{{ req.url }}?editor=true', function(data) {
            var cont = $('div.minerva_content');
            cont.html(data);
            });
          return false;
          })();
          ">Edit</a>
    {% endif %}

    {% block attributes %}{% endblock %}

  {% endif %}
</div>

</div>
